#pragma once

#include "mqtt_client.h"
#include "ArduinoJson.h"
#include "WiFi.h"

class MqttBaseMessage
{
    public:
    MqttBaseMessage()
    {
        id = "123";
        version = "V111";
        topic = "MqttTopicsUp";
        payload = "";
        err = 0;
    }
    int err;
    String id;
    String version;
    String topic;
    String payload;
};

class MqttReplayMessage : public MqttBaseMessage
{
    public:
    MqttReplayMessage(){}
    virtual String JsonObj(DynamicJsonDocument &data)
    {
        DynamicJsonDocument doc(1024);
        doc["id"] = id;
        doc["version"] = version;
        doc["datetime"] = "";
        doc["rssi"] = WiFi.RSSI();
        doc["data"] = data;
        serializeJsonPretty(doc,payload);
        return payload;
    }
    String msg;
};





void on_topic_msg_down(esp_mqtt_event_handle_t event);